var model = avalon.define("home", function(vm) {
	//根据屏幕尺寸换图片
	var slide1BigImg = "img/home/home_slide1.png";
	var slide1SMImg = "img/mobile/home/home_slide1.jpg";
	
	vm.slide1Img = slide1BigImg;
	
	var slide2BigImg = "img/home/home_slide2.png";
	var slide2SMImg = "img/mobile/home/home_slide2.jpg";
	
	vm.slide2Img = slide2BigImg;
	
	var slide3BigImg = "img/home/home_slide3.png";
	var slide3SMImg = "img/mobile/home/home_slide3.jpg";
	
	vm.slide3Img = slide3BigImg;
	
	var slide4BigImg = "img/home/home_slide4.png";
	var slide4SMImg = "img/mobile/home/home_slide4.jpg";
	
	vm.slide4Img = slide1BigImg;
	
	//设置大图
	function setBigImg(){
		var width = document.body.clientWidth;
		if(width < 768){
			vm.slide1Img = slide1SMImg;
			vm.slide2Img = slide2SMImg;
			vm.slide3Img = slide3SMImg;
			vm.slide4Img = slide4SMImg;
		}
		else{
			vm.slide1Img = slide1BigImg;
			vm.slide2Img = slide2BigImg;
			vm.slide3Img = slide3BigImg;
			vm.slide4Img = slide4BigImg;
		}
			
	};
	setBigImg();
	
	//显示轮转图
	vm.showFeaturesPromo = function(promoIndex){
		var width = document.body.clientWidth;
		if(width < 768)
			return;
		
		$('#home_features_block_slide').slideDown();
		$('#carouselHomePromot').carousel(promoIndex);
	};
	
	//关闭轮转图
	vm.dismissFeaturesPromo = function(){
		$('#home_features_block_slide').slideUp();
	};
	
	//监听屏幕尺寸
	vm.$watch('resize',function(){
		var width = document.body.clientWidth;
		if(width < 768){
			$('#home_features_block_slide').css('display','none');
		}
		
		setBigImg();
	});
	
	//鼠标在上时
	vm.mouseHover = function(){
		var imgSrc = this.src;
		this.src = imgSrc.substr(0,imgSrc.lastIndexOf('.png')) + "-pre.png";
	};
	
	//鼠标出按钮时
	vm.mouseOut = function(){
		var imgSrc = this.src;
		this.src = imgSrc.substr(0,imgSrc.lastIndexOf('-pre.png')) + ".png";
	}

	//鼠标在新闻图片上时
	vm.newsImgHover = function(){
		var mask = $(this).next();
		var maskText = mask.next();
		mask.css({"width":this.width,"height":this.height,"display":"block"});
		maskText.css({"width":this.width/3*2,"height":this.height/3*2,'display':'block','top':this.height/6});
	};

	//鼠标出新闻图片上时
	vm.newsImgOut = function(){
		this.style.display = 'none';
		$(this).next().css('display','none');
	};

	//鼠标入新闻文字区域bug
	vm.maskTextHover = function () {
		this.style.display = 'block';
		$(this).prev().css('display','block');
	}
	var screenWidth= document.documentElement.clientWidth;	
	vm.videoWidth=screenWidth > 768 ? screenWidth*0.6:screenWidth*0.9;
	vm.videoHeight=vm.videoWidth*2/3;
	//弹出视频播放层---2015.5.13--JackYan	  
	vm.showVideoPage=function(){console.log(vm.videoWidth+"  "+vm.videoHeight);		
	if(screenWidth<1000){
		window.open("http://www.56.com/u45/v_MTM3MjMxMTk0.html","史上最便捷的教学辅助工具");
	}else{
		var i = $.layer({
				  type : 1, 				 		
   				  title:false,
   				  move:"#myEmbed",
   				  moveType:0,
   				  border:[0],
// 				  area: [ vm.videoWidth+'px', vm.videoHeight+'px'],
                  area:['auto',"auto"],
   				  page : {dom : '#myEmbed'}
						});
	}
		

       }	
      
});
avalon.scan();